/**
* Vista asociada al contenido 
* con la interfaz principal que muestra LOGIN e INFORMACION
* en el aplicativo.
*/
Ext.define("entgpv11.view.MainContainer", {
    extend: 'Ext.tab.Panel',
    id: 'splashScreen',
    //'Ext.device.Connection',
    requires: ['Ext.TitleBar',
	'entgpv11.view.MainContainer.Login',
	'entgpv11.view.MainContainer.Info'
	],
    alias: "widget.maincontainer",
    config:
    {
        scrollable: 'vertical',
        tabBarPosition: 'bottom',
        versionString:'0'
    },
    initialize: function () {
        this.callParent(arguments);
        this.type = 0;
        var imgTop = {
            xtype: 'image',
            height: 201
        };

        var tabs01 = {
            xtype: "login",
            title: 'Inicio',
            iconCls: 'user_send',
            iconMask: true,
            ui: "plain"
        };
        var tabs02 = {
            title: 'Creditos',
            iconCls: 'info',
            xtype: "info",
            versionString:this.getVersionString()
        };
        this.type = this.onExitIf();

        if (this.type > 0) {
            var exitIcon = {
                title: 'Salir',
                iconCls: 'action',
                html: '',
                listeners: {
                    active: { fn: this.onExit, scope: this }
                }
            };

            this.add(
                        [
                                {
                                    docked: 'top',
                                    xtype: 'titlebar',
                                    id: 'splashToolbar',
                                    title: 'Service Project'
                                },
				                tabs01,
                                tabs02,
                                exitIcon
                        ]
                );
        }
        else {
            if (this.type == -1)
            { 
                    this.add(
                    [{
                        docked: 'top',
                        xtype: 'titlebar',
                        id: 'splashToolbar',
                        title: 'Service Project'
                    },
                     tabs02
                ]);


            } 
            else
            {
                this.add(
                [
                        {
                            docked: 'top',
                            xtype: 'titlebar',
                            id: 'splashToolbar',
                            title: 'Service Project'
                        },
				        tabs01,
                        tabs02
                ]);
                   
            }
       


        }

        this.on({
            scope: this,
            activeitemchange: this.onExit
        });
    },
    onExit: function (me, newActiveItem, oldActiveItem, eOpts) {

        this.fireEvent("exitCommand", me, newActiveItem, oldActiveItem, this.type);
    },
    onExitIf: function () {
        var _type = 0;
        //if (Ext.device.Connection.isOnline())
        //    _type = -1;
        if (navigator.userAgent.match(/(BlackBerry)/))
            _type = 0; //1

        if (navigator.userAgent.match(/(iPhone|iPod|iPad)/))
            _type = 0; //2

        if (navigator.userAgent.match(/(Android)/))
            _type = 0; //3

        return (_type);
    }


});